package com.xuyiwei.xblog.core.base.constant.enums;

import com.xuyiwei.xblog.core.base.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * 业务是否成功的日志记录
 *
 * @author fengshuonan
 * @Date 2017年1月22日 下午12:14:59
 */
public enum LogSucceed implements ConstantStatusInterface<String,String> {
    NULL("", ""),
    SUCCESS("success", "成功"),
    FAIL("fail", "失败");

    private String key;
    private String desc;

    LogSucceed(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    static Map<String, LogSucceed> map = new HashMap<>();

    static {
        for (LogSucceed bst : LogSucceed.values()) {
            map.put(bst.key, bst);
        }
    }

    public static LogSucceed convert(Integer key) {
        LogSucceed type = map.get(key);
        return (type != null) ? type : NULL;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getDesc() {
        return desc;
    }
}
